package com.cssl.service.impl;

import ch.qos.logback.core.net.SyslogOutputStream;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.cssl.dao.EmpDao;
import com.cssl.pojo.Emp;
import com.cssl.service.EmpService;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Transactional
@Service
public class EmpServiceImpl extends ServiceImpl<EmpDao,Emp> implements EmpService {

    @Autowired
    private EmpDao eDao;

    public EmpServiceImpl() {
        System.out.println("EmpServiceImpl");
    }

    /*@Override
    public Page<Map<String,Object>> selectMap(int pageindex, int pagesize) {

        Page<Map<String,Object>> page= PageHelper.startPage(pageindex, pagesize);
        eDao.selectMap();
        System.out.println(page.size());
        return page;
    }*/

    @Override
    public List<Map<String, Object>> select() {
        return eDao.selectMap();
    }
    //总页数
    @Override
    public int selectCount() {
        int pageCount=eDao.selectCount()%3==0?eDao.selectCount()/3:eDao.selectCount()/3+1;
        return pageCount;
    }

    @Override
    public IPage<Emp> findAll(Page<Emp> page) {
        return eDao.findAll(page);
    }


}
